import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Solution {
    public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {
        List<List<Integer>> answer = new ArrayList<>();
        answer.add(new ArrayList<>());
        answer.add(new ArrayList<>());
        Set<Integer> set1 = new HashSet<>();
        Set<Integer> set2 = new HashSet<>();
        //将nums1的值加入set1
        for (int x : nums1) {
            set1.add(x);
        }
        //将nums2的值加入set2
        for (int x : nums2) {
            set2.add(x);
        }
        for (int x : set1) {
            if (!set2.contains(x)) {
                answer.get(0).add(x);
            }
        }
        for (int x : set2) {
            if (!set1.contains(x)) {
                answer.get(1).add(x);
            }
        }
        return answer;
    }
}
